package com.aco.fatureapp.utilitary;

import java.lang.reflect.Field;

import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;

/**
 * 
 */
public class TypefaceUtil {

	/**
	 * 
	 * @param context
	 * @param defaultFont
	 * @param customFont
	 */
	public static void overrideFont(final Context context,
			final String defaultFont, final String customFont) {
		try {
			final Typeface customFontTypeface = Typeface.createFromAsset(
					context.getAssets(), customFont);

			final Field defaultFontTypefaceField = Typeface.class
					.getDeclaredField(defaultFont);

			defaultFontTypefaceField.setAccessible(true);

			defaultFontTypefaceField.set(null, customFontTypeface);
		} catch (final Exception ex) {
			Log.e("Error override fonte", ex.getLocalizedMessage());
		}
	}

	/**
	 * 
	 * @param context
	 * @return
	 */
	public static Typeface getDefaultFont(Context context) {
		return Typeface.createFromAsset(context.getAssets(),
				"fonts/VarelaRound-Regular.ttf");
	}
}